package Pacote1;

import grails.test.*
import les.*

class CrudEncontroTests extends functionaltestplugin.FunctionalTestCase {
	
	void testApenasNome() {
		get ("/usuario/login")
		
		form() {
			email = "jota@gmail.com"
			senha = "123456"
			click "entrar"
		}
		
		redirectEnabled = false
		get ("/encontro/create")
		
		form() {
			tema = "teste"
			click "create"
		}
		
		assertRedirectUrlContains "/encontro/show"
		followRedirect()
		redirectEnabled = true
		
		
		assertContentContains "Encontro criado(a) com sucesso"
		assertContentContainsStrict "<td valign=\"top\" class=\"name\">Tema</td>"
		assertContentContainsStrict "<td valign=\"top\" class=\"value\">teste</td>"
	}
	
	void testSemNome() {
		get ("/usuario/login")
		
		form() {
			email = "jota@gmail.com"
			senha = "123456"
			click "entrar"
		}
		
		get ("/encontro/create")
		
		form() {
			lema = "teste"
			click "create"
		}
		
		assertContentContains "O campo tema n&atilde;o pode ficar em branco";
	}
	
	void testCricaoCompleta(){
		get ("/usuario/login")
		
		form() {
			email = "jota@gmail.com"
			senha = "123456"
			click "entrar"
		}
		
		redirectEnabled = false
		get ("/encontro/create")
		
		form() {
			tema = "teste"
			musicaTema = "Ser diferente"
			lema = "Para Deus nada � imposs�vel"
			click "create"
		}
		
		assertRedirectUrlContains "/encontro/show"
		followRedirect()
		redirectEnabled = true
		
		assertContentContains "Encontro criado(a) com sucesso"
		assertContentContainsStrict "<td valign=\"top\" class=\"name\">Tema</td>"
		assertContentContainsStrict "<td valign=\"top\" class=\"value\">teste</td>"
	}
}